home *** CD-ROM | disk | FTP | other *** search
-
- /*************************************************************************
- *
- * WReferenceObject
- *
- * Implements a base class for referenced objects.
- *
- *************************************************************************/
-
- #ifndef _WREFOBJ_HPP_INCLUDED
- #define _WREFOBJ_HPP_INCLUDED
-
- #ifndef _WNO_PRAGMA_PUSH
- #pragma pack(push,8);
- #pragma enum int;
- #endif
-
- //
- // WReferenceObject
- //
-
- class WCMCLASS WReferenceObject : public WObject {
- WDeclareSubclass( WReferenceObject, WObject );
-
- /**********************************************************
- * Constructors and Destructors
- *********************************************************/
-
- // This class is meant to be used as a reference class, with
- // objects allocated via new. As such we don't allow
- // copies to be made except via explicitly-defined copy
- // methods.
- //
- // All objects are allocated via a static function.
-
- protected:
- WReferenceObject( const WReferenceObject & ref );
- WReferenceObject& operator=( const WReferenceObject & ref );
-
- protected:
- WReferenceObject();
-
- public:
- ~WReferenceObject();
-
- /**********************************************************
- * Properties
- *********************************************************/
-
- // ReferenceCount
-
- virtual WLong GetReferenceCount() const;
-
- /**********************************************************
- * Methods
- *********************************************************/
-
- // Reference
- //
- // Increments the reference count for the object.
- // Note that Reference is called once when the object
- // is created.
-
- virtual WLong Reference();
-
- // Unreference
- //
- // Decrements the reference count for the object.
- // When the reference count reaches 0, the object
- // releases/frees the global memory object and
- // then does "delete this". If the returned value is
- // 0 or less, DON'T USE THE OBJECT!
-
- virtual WLong Unreference();
-
- /**********************************************************
- * Private
- *********************************************************/
-
- protected:
- virtual void ReinitSelf();
- virtual void DeleteSelf();
-
- protected:
- WLong _refCount;
- };
-
-
- #ifndef _WNO_PRAGMA_PUSH
- #pragma enum pop;
- #pragma pack(pop);
- #endif
-
- #endif // _WREFOBJ_HPP_INCLUDED
-